package shaders;

import helpers.ColorHelper;

import java.awt.Color;
import java.awt.image.BufferedImage;

import javax.vecmath.Vector3d;

import essential.Ray;

public class CloudsShader extends Shader {

	public CloudsShader(){
		int width = 800;
		int height = 800;
		
		textureImage = new BufferedImage(width, height,BufferedImage.TYPE_INT_RGB);
	}

	@Override
	public Color calculateColor2d(int x, int y) {

		if(!textureIsSet){
			createTexture();
			textureIsSet = true;
		}
		
		
		return new Color(textureImage.getRGB(x, y));
	}
	
	@Override
	public Color textureColor(double x, double y) {
		double amount = Math.sin(x*y+ 20*per.turbulence(x,y,32));
		
		return  ColorHelper.sumColor(
				ColorHelper.mulColor(color, amount),
				ColorHelper.mulColor(gradientColor, 1-amount)
		);		
		
	}

	
	@Override
	public Color calculateColor3d(Ray r, Vector3d sp) {
		return null;
	}

	@Override
	public Shader copy() {
		Shader s = new CloudsShader();
		this.copyFromTo(this,s);
		return s;
	}

	@Override
	public double fBump(double x, double y, double z) {
		return 0;
	}

	

}
